|
|
|
|
|
|
|
Dealing with User Expectations |
|
|
|
|
|
|
|
|
Users tend to have ideas about how they think Windows applications should behave. Some of these ideas make sense, and some do not. Most likely, these notions are derived from features they have seen in commercial programs. Of course, users will then expect every simple VB program you write to behave in exactly the same way. |
|
|
|
|
|
|
|
|
For example, even though your program may have an Exit button, you can count on users to click the Close button in the upper-right corner. If you forget to add code to the Form_Unload event to handle this situation, your application could keep running when you don't want it to. The following sections describe several things about which you can count on users having expectations. |
|
|
|
|
|
|
|
|
Many users expect list boxes to behave a certain way. Suppose a list box is set up in a dialog box to select a single item. Some users may prefer to just double-click the item, whereas others single-click it and then press Enter or click OK. These alternative methods are easy to include in your program; simply remember to add code to the list box's DblClick event. |
|
|
|
|
| |
|
|
|
|
In the example described here of selecting items from a list box, both single-clicking and double-clicking are appropriate. However, there are users who do not understand when to use a single-click versus a double-click. You can easily spot these people because they tend to double-click everything, including hyperlinks, command buttons, and even menus. Help teach them the correct procedure by using the hourglass mouse pointer and providing instructions that say specifically whether to single- or double-click. |
|
|
|
|
|
|
|
|
|
|
See "The List Box" p. 70 |
|
|
|
|
|
|
|
|
Another list box feature available in commercial programs is the ability to enter letters on the keyboard to jump to a specific list item. By default, the list box accepts only a single character. However, you can easily add this "type-ahead" feature to your list box. Simply accumulate the entered characters from the KeyPress event in a string, and then move to the matching item in the list. The code in Listing 18.1 does this, plus provides the additional feature of a Timer control that gradually fills the list box. This capability allows users to begin using the type-ahead feature before the list is completely filled. |
|
|
|
|
|
|
|
|
Listing 18.1 LISTBOX.ZIPAdding Keyboard Search to a List Box |
|
|
|
|
|
|
|
|
Option Explicit
Dim sLstSearch As String 'The search string
Dim CurrentLetter As String 'Letter being loaded into the list
Dim sWaitForLetter As String 'Letter not yet loaded but selected
Dim dbBiblio As Database 'The sample VB "biblio" database
Private Sub Form_Load() |
|
|
|
|
|